{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 290,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from scipy import stats # 求概率密度\n",
    "from IPython.display import display # 使打印的表格对齐"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>货运总量</th>\n",
       "      <th>工业总产值</th>\n",
       "      <th>农业总产值</th>\n",
       "      <th>居民非商业支出</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>编号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>160</td>\n",
       "      <td>70</td>\n",
       "      <td>35</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>260</td>\n",
       "      <td>75</td>\n",
       "      <td>40</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>210</td>\n",
       "      <td>65</td>\n",
       "      <td>40</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>265</td>\n",
       "      <td>74</td>\n",
       "      <td>42</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>240</td>\n",
       "      <td>72</td>\n",
       "      <td>38</td>\n",
       "      <td>1.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>220</td>\n",
       "      <td>68</td>\n",
       "      <td>45</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>275</td>\n",
       "      <td>78</td>\n",
       "      <td>42</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>160</td>\n",
       "      <td>66</td>\n",
       "      <td>36</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>275</td>\n",
       "      <td>70</td>\n",
       "      <td>44</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>250</td>\n",
       "      <td>65</td>\n",
       "      <td>42</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    货运总量  工业总产值  农业总产值  居民非商业支出\n",
       "编号                             \n",
       "0    160     70     35      1.0\n",
       "1    260     75     40      2.4\n",
       "2    210     65     40      2.0\n",
       "3    265     74     42      3.0\n",
       "4    240     72     38      1.2\n",
       "5    220     68     45      1.5\n",
       "6    275     78     42      4.0\n",
       "7    160     66     36      2.0\n",
       "8    275     70     44      3.2\n",
       "9    250     65     42      3.0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dic1 = {'货运总量':[160,260,210,265,240,220,275,160,275,250],\n",
    "        '工业总产值':[70,75,65,74,72,68,78,66,70,65],\n",
    "        '农业总产值':[35,40,40,42,38,45,42,36,44,42],\n",
    "        '居民非商业支出':[1.0,2.4,2.0,3.0,1.2,1.5,4.0,2.0,3.2,3.0]}\n",
    "df1 = pd.DataFrame(dic1)\n",
    "df1.index.name = '编号' \n",
    "# df1.insert(1,'常数项',[1 for i in range(len(df1))])\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 347,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Regreession():\n",
    "    '''\n",
    "    df: 第一列为Y，其他列为X变量的DataFrame\n",
    "    a: 置信系数\n",
    "    standerd: 是否标准化数据\n",
    "    \n",
    "    '''\n",
    "    def __init__(self, df, a=0.05,standard=False):\n",
    "        self.df = df\n",
    "        self.standard = standard\n",
    "        if self.standard == False: # 如果数据不标准化\n",
    "            self.Y = df.iloc[:,0]\n",
    "            X = df.iloc[:,1:]\n",
    "            X.insert(0,'常数项',[1 for i in range(len(df))]) # X矩阵插入常数项\n",
    "            self.X = X\n",
    "        else:\n",
    "            self.Y,self.X = Regreession.standard_data(self)\n",
    "        self.a = 0.05\n",
    "        self.beta = Regreession.beta(self) # 调用下面的函数计算β\n",
    "        self.y_hat = Regreession.y_hat(self)\n",
    "        self.sigma2 = Regreession.sigma2(self)\n",
    "        \n",
    "    # 标准化数据\n",
    "    def standard_data(self):\n",
    "        Y = self.df.iloc[:,0]\n",
    "        Y = (Y-np.mean(Y))/np.sqrt(np.sum(np.square(Y-np.mean(Y))))\n",
    "        X = self.df.iloc[:,1:]\n",
    "        X = (X-np.mean(X))/np.sqrt(np.sum(np.square(X-np.mean(X))))\n",
    "        #X.insert(0,'常数项',[0 for i in range(len(self.df))]) # X矩阵插入常数项\n",
    "        return Y, X\n",
    "    \n",
    "    # 计算相关矩阵函数\n",
    "    def r(self): \n",
    "        column = ['x%d'%i for i in range(1,len(df1.columns))]\n",
    "        column.insert(0,'y1')\n",
    "        df = pd.DataFrame(columns=column,index=column)\n",
    "    # 默认第一列为y\n",
    "        r = np.zeros(shape=(self.df.shape[1],self.df.shape[1]))  # 初始化简单相关系数矩阵\n",
    "        for n1,i in enumerate(self.df):\n",
    "            for n2,j in enumerate(self.df):\n",
    "                a = np.sum((self.df[i]-np.mean(self.df[i]))*(self.df[j]-np.mean(self.df[j]))) # 分子\n",
    "                b = np.sqrt(np.sum(np.square(self.df[i]-np.mean(self.df[i])))*np.sum(np.square(self.df[j]-np.mean(self.df[j])))) # 分母\n",
    "                r[n1,n2] = a/b\n",
    "                df.iloc[n1,n2] = round(a/b,3)\n",
    "\n",
    "        r = np.around(r,3) # 保留3位小数\n",
    "        print('简单相关系数矩阵：r='); display(df)\n",
    "    \n",
    "    # 计算β\n",
    "    def beta(self):\n",
    "        beta = np.dot(np.dot(np.linalg.inv(np.dot(np.transpose(self.X),self.X)),np.transpose(self.X)),self.Y) # (X'X)^(-1)=np.linalg.inv(np.dot(np.transpose(X),X))\n",
    "        beta_ = np.around(beta,4)\n",
    "        if self.standard == True:\n",
    "            output_ = '标准化的回归方程：y = '\n",
    "            output2_ = [f' {beta_[i]}·x_{i}i + ' for i in range(0,len(beta_)-1)];\n",
    "            output3 = f' {beta_[len(beta)-1]}·x_{len(beta)-1}i'\n",
    "            print(output_,''.join(output2_),output3)\n",
    "        else:\n",
    "            output = f'未标准化的回归方程：y = {beta_[0]}'\n",
    "            output2 = [f' + {beta_[i]}·x_{i}i' for i in range(1,len(beta_))]\n",
    "            print(output,''.join(output2))\n",
    "        return beta_\n",
    "    \n",
    "    # 预测y值\n",
    "    def y_hat(self,X=False):\n",
    "        if X == False:                                            # 加入指定x1，x2，x3，求一个y时\n",
    "            y_hat = np.dot(self.X,self.beta)\n",
    "        else:\n",
    "            y_hat = np.dot(X,self.beta)\n",
    "        return y_hat\n",
    "    \n",
    "    # 计算可决系数R2\n",
    "    def R2(self):\n",
    "        R2 = np.sum(np.square(self.y_hat-np.mean(self.Y)))/np.sum(np.square(self.Y-np.mean(self.Y)))\n",
    "        print(f'可决系数 R^2 ：{R2}')\n",
    "        # return R2\n",
    "\n",
    "    # F检验\n",
    "    def F_test(self): \n",
    "        F = ( np.sum(np.square(self.y_hat-np.mean(self.Y)))/(self.X.shape[1]-1) )/( np.sum(np.square(self.Y-self.y_hat))/(self.Y.shape[0]-self.X.shape[1]-1) )\n",
    "        n1 = self.X.shape[1]-1; n2 = self.Y.shape[0]-self.X.shape[1]-1\n",
    "        p_value = 1 - stats.f.cdf(F,n1,n2)                         # 累计分布求分位数\n",
    "        p_value = round(p_value,4)\n",
    "        print(f'F检验：P值 = {p_value}')\n",
    "\n",
    "    # 计算^σ2\n",
    "    def sigma2(self):\n",
    "        e2 = np.sum(np.square(self.Y-self.y_hat))                  # 残差平方和e^2\n",
    "        sigma2_ = (1/(self.Y.shape[0]-self.X.shape[1]))*e2         # 方差预测^σ^2\n",
    "        return sigma2_\n",
    "    \n",
    "    # t检验,β置信区间\n",
    "    def t_test(self):\n",
    "        '''\n",
    "        confidence_interval: 是否显示置信水平\n",
    "        a: 置信水平\n",
    "        '''\n",
    "        df = pd.DataFrame(index=self.X.columns,columns=['系数','t检验_p值','置信区间'])\n",
    "        df.index.name = '变量'\n",
    "        df['系数'] = self.beta\n",
    "        X_X = np.linalg.inv(np.dot(np.transpose(self.X),self.X)) # (X'X)^(-1)\n",
    "        for n,j in enumerate(self.beta):\n",
    "            cjj = X_X[n,n]\n",
    "            t_j = self.beta[n]/np.sqrt(self.sigma2*cjj)\n",
    "            free_n = self.Y.shape[0]-self.X.shape[1]                # 自由度\n",
    "            p_j = 1 - stats.t.cdf(t_j,free_n)\n",
    "            df.iloc[n,1] = round(p_j,4)\n",
    "\n",
    "            # 置信区间\n",
    "            beta_lp = self.beta[n] + stats.t.ppf(self.a/2,free_n)\n",
    "            beta_ub = self.beta[n] - stats.t.ppf(self.a/2,free_n)\n",
    "            df.iloc[n,2] = '[%.3f，%.3f]'%(beta_lp,beta_ub)\n",
    "\n",
    "        display(df)\n",
    "    \n",
    "    # 预测y置信区间\n",
    "    def y_hat_interval(self,X):\n",
    "        X.insert(0,1)                                               # 常数项\n",
    "        y_hat = Regreession.y_hat(self,X)\n",
    "        y_hat_lb = y_hat - 2*np.sqrt(self.sigma2); y_hat_lb = round(y_hat_lb,3)\n",
    "        y_hat_ub = y_hat + 2*np.sqrt(self.sigma2); y_hat_ub = round(y_hat_ub,3)\n",
    "        print('y的预测值为%.4f'%y_hat)\n",
    "        print(f'y的95%预测区间为 [ {y_hat_lb}, {y_hat_ub} ]')\n",
    "    \n",
    "    # 总结果\n",
    "    def summary(self):\n",
    "        Regreession.r(self)\n",
    "        print('')\n",
    "        Regreession.R2(self)\n",
    "        print('------------------------')\n",
    "        Regreession.F_test(self)\n",
    "        # print('')\n",
    "        Regreession.t_test(self)\n",
    "        Regreession(self.df) # 回归方程"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 348,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "未标准化的回归方程：y = -348.2802  + 3.754·x_1i + 7.1007·x_2i + 12.4475·x_3i\n"
     ]
    }
   ],
   "source": [
    "rs = Regreession(df1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 349,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "简单相关系数矩阵：r=\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>y1</th>\n",
       "      <th>x1</th>\n",
       "      <th>x2</th>\n",
       "      <th>x3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>y1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.556</td>\n",
       "      <td>0.731</td>\n",
       "      <td>0.724</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x1</td>\n",
       "      <td>0.556</td>\n",
       "      <td>1</td>\n",
       "      <td>0.113</td>\n",
       "      <td>0.398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x2</td>\n",
       "      <td>0.731</td>\n",
       "      <td>0.113</td>\n",
       "      <td>1</td>\n",
       "      <td>0.547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x3</td>\n",
       "      <td>0.724</td>\n",
       "      <td>0.398</td>\n",
       "      <td>0.547</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       y1     x1     x2     x3\n",
       "y1      1  0.556  0.731  0.724\n",
       "x1  0.556      1  0.113  0.398\n",
       "x2  0.731  0.113      1  0.547\n",
       "x3  0.724  0.398  0.547      1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "可决系数 R^2 ：0.8055031367858719\n",
      "------------------------\n",
      "F检验：P值 = 0.0315\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>系数</th>\n",
       "      <th>t检验_p值</th>\n",
       "      <th>置信区间</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>变量</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>常数项</td>\n",
       "      <td>-348.2802</td>\n",
       "      <td>0.9521</td>\n",
       "      <td>[-350.727，-345.833]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>工业总产值</td>\n",
       "      <td>3.7540</td>\n",
       "      <td>0.0501</td>\n",
       "      <td>[1.307，6.201]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>农业总产值</td>\n",
       "      <td>7.1007</td>\n",
       "      <td>0.0244</td>\n",
       "      <td>[4.654，9.548]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>居民非商业支出</td>\n",
       "      <td>12.4475</td>\n",
       "      <td>0.1418</td>\n",
       "      <td>[10.001，14.894]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               系数  t检验_p值                 置信区间\n",
       "变量                                            \n",
       "常数项     -348.2802  0.9521  [-350.727，-345.833]\n",
       "工业总产值      3.7540  0.0501        [1.307，6.201]\n",
       "农业总产值      7.1007  0.0244        [4.654，9.548]\n",
       "居民非商业支出   12.4475  0.1418      [10.001，14.894]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "未标准化的回归方程：y = -348.2802  + 3.754·x_1i + 7.1007·x_2i + 12.4475·x_3i\n"
     ]
    }
   ],
   "source": [
    "rs.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 350,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y的预测值为270.0865\n",
      "y的95%预测区间为 [ 223.203, 316.97 ]\n"
     ]
    }
   ],
   "source": [
    "# y预测区间\n",
    "rs.y_hat_interval(X=[75,42,3.1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 标准化回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 351,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "标准化的回归方程：y =   0.3848·x_0i +  0.5355·x_1i +   0.2771·x_2i\n",
      "简单相关系数矩阵：r=\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>y1</th>\n",
       "      <th>x1</th>\n",
       "      <th>x2</th>\n",
       "      <th>x3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>y1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.556</td>\n",
       "      <td>0.731</td>\n",
       "      <td>0.724</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x1</td>\n",
       "      <td>0.556</td>\n",
       "      <td>1</td>\n",
       "      <td>0.113</td>\n",
       "      <td>0.398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x2</td>\n",
       "      <td>0.731</td>\n",
       "      <td>0.113</td>\n",
       "      <td>1</td>\n",
       "      <td>0.547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>x3</td>\n",
       "      <td>0.724</td>\n",
       "      <td>0.398</td>\n",
       "      <td>0.547</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       y1     x1     x2     x3\n",
       "y1      1  0.556  0.731  0.724\n",
       "x1  0.556      1  0.113  0.398\n",
       "x2  0.731  0.113      1  0.547\n",
       "x3  0.724  0.398  0.547      1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "可决系数 R^2 ：0.8055998510739624\n",
      "------------------------\n",
      "F检验：P值 = 0.0074\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>系数</th>\n",
       "      <th>t检验_p值</th>\n",
       "      <th>置信区间</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>变量</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>工业总产值</td>\n",
       "      <td>0.3848</td>\n",
       "      <td>0.0371</td>\n",
       "      <td>[-1.980，2.749]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>农业总产值</td>\n",
       "      <td>0.5355</td>\n",
       "      <td>0.0162</td>\n",
       "      <td>[-1.829，2.900]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>居民非商业支出</td>\n",
       "      <td>0.2771</td>\n",
       "      <td>0.122</td>\n",
       "      <td>[-2.088，2.642]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             系数  t检验_p值            置信区间\n",
       "变量                                     \n",
       "工业总产值    0.3848  0.0371  [-1.980，2.749]\n",
       "农业总产值    0.5355  0.0162  [-1.829，2.900]\n",
       "居民非商业支出  0.2771   0.122  [-2.088，2.642]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "未标准化的回归方程：y = -348.2802  + 3.754·x_1i + 7.1007·x_2i + 12.4475·x_3i\n"
     ]
    }
   ],
   "source": [
    "rs_standard = Regreession(df1,standard=True)\n",
    "rs_standard.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
